package com.example.springcloud.order.feign;

import com.example.springcloud.order.result.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 库存服务 Feign 客户端
 */
@FeignClient(value = "storage-service", path = "/storage")
public interface StorageServiceFeign {

    /**
     * 扣减库存 - AT 模式
     */
    @PostMapping("/deduct")
    Result<Void> deduct(@RequestParam("productId") Long productId,
                        @RequestParam("count") Integer count);

    /**
     * 扣减库存 - TCC Try 阶段
     */
    @PostMapping("/deduct/tcc/try")
    Result<Void> deductTccTry(@RequestParam("productId") Long productId,
                              @RequestParam("count") Integer count);

    /**
     * 扣减库存 - XA 模式
     */
    @PostMapping("/deduct/xa")
    Result<Void> deductXa(@RequestParam("productId") Long productId,
                          @RequestParam("count") Integer count);
}

